خلاصه نویسی های برنامه نویسی پایتون



#!cd /Users/apple/Desktop/all
cd /Users/apple/Downloads/money_heist/season_1
for n in *.srt;
do
echo "rename $n"
r=${n/.Farsi.Dubbed/.x265.PSA}
#!f=${n/La.casa.de.papel./Money.Heist.}
#!h=${f/.WEBRip.Netflix/.1080p.WEB-DL.Farsi.Dubbed}
echo $r
mv "/Users/apple/Downloads/money_heist/season_1/$n" "/Users/apple/Downloads/money_heist/season_1/$r"
done

#!La.casa.de.papel.S01E01.WEBRip.Netflix.srt
#!Money.Heist.S01E01.1080p.WEB-DL.Farsi.Dubbed
#!Money.Heist.S01E05.1080p.WEB-DL.x265.PSA

 

یه سری خلاصه بش:

c="amirasfasf343434"
echo $c
echo ${c}
echo ${#c} counts number of chars in c
echo ${c:4}  prints from index 4 to end (4 included)
echo ${c:4:5} prints 5 chars starting from index 4 (4 included)
d=${c/remove/replace}

فقط نمی دونم چرا برا من فقط اون اولی رو eplace می کنه  

آموزش بش خوب:

https://amirsamimi.ir/bash_tutorials/

عاشق بش شدم :)


import docx

doc = docx.Document('/Users/apple/Desktop/پایا ن خوب.docx')


mp=dict()

for para in doc.paragraphs:
    s=para.text
    alphanumeric_filter = filter(lambda x: str.isalnum(x) or x==' ', s)
    alphanumeric_string = "".join(alphanumeric_filter)
    t=alphanumeric_string.split(' ')
    for k in t:
        if k in mp.keys():
            mp[k]+=1
        else:
            mp[k]=1
#    print (alphanumeric_string) 

surted= dict(sorted(mp.items(), key=lambda item: -item[1]))
print('len is %i'%len(surted))
n=0
for f in surted:
    print (f,surted[f])
    n+=1
    if n>100:
        break

 


import mysql.connector

def valid (s):
    if s=='' or len(s)==0:
        return False
    if s.count('@')!=1:
        return False
    if s.count('.')!=1:
        return False
    
    t=s.index('@')
    p=s.index('.')
    f=s[:t]
    m=s[t+1:p]
    l=s[p+1:]

    if f.isalnum() and m.isalpha() and l.isalpha():
        return True
    else:
        return False

databasename='shotor'

cnx= mysql.connector.connect(user='root',password='',
                             host='127.0.0.1',
                             database=databasename)
cursor=cnx.cursor()
tablename='data'
#cursor.execute('CREATE table %s (username varchar(20), password varchar(20));'%tablename)
#cnx.commit()


username='?'
password='?'

s=input()
while valid(s)==False:
    print('please enter a valid email address like this: username@something.something')
    s=input()
username=s

s=input()
while s.isalnum()==False:
    print('password can only contain alphabet and digits')
    s=input()
password=s
cursor.execute('INSERT INTO %s VALUES(\'%s\',\'%s\')'%(tablename,username,password))

cnx.commit()
cnx.close()

 


import mysql.connector

cnx= mysql.connector.connect(user='root',password='',
                             host='127.0.0.1',
                             database='mysql')

cursor=cnx.cursor()
query= 'SELECT * from colgs'
cursor.execute(query)
people=[]
for (name,weight,height) in cursor:
    people.append((name,weight,height))

people.sort (key= lambda x:(-x[2],x[1]) )
for i in people:
    print (i[0],i[1],i[2])
cnx.close()

 


import mysql.connector

print ("wants to connect")

cnx= mysql.connector.connect(user='newuser',password='user_password',
                             host='127.0.0.1',
                             database='shotor')

print('connected successfully') 
cursor=cnx.cursor()
query= 'SELECT * from friends'
cursor.execute(query)

for (name,phone,stat) in cursor:
    print ('My friend %s number: %s and they are %savailable now%s'%(
    "{0:>8}".format(name),"{0:>9}".format(phone),''if stat=='y' else 'not ','!'if stat=='y' else ' :('))

cnx.close()

 


import mysql.connector

print ("wants to connect")

cnx= mysql.connector.connect(user='newuser',password='user_password',
                             host='127.0.0.1',
                             database='shotor')

print('connected successfully') 
cursor=cnx.cursor()
cursor.execute('INSERT INTO friends VALUES (\'havij\',9234233,\'y\')')
cursor.execute('INSERT INTO friends VALUES (\'khers\',\'216673\',\'n\')')
name='Feeeel'
number=212622
stats='y'
cursor.execute('INSERT INTO friends VALUES (\'%s\',\'%d\',\'%c\')'%(name,number,stats))


cnx.commit()
cnx.close()

 


تبلیغات

آخرین ارسال ها

آخرین جستجو ها

Gold سالک ایرانی اسلامی اولین مرجع نرم افزار های کمیاب و نایاب در ایران A.T.I کلینیک های برتر گفتاردرمانی و کاردرمانی تولید کود از زباله ( کمپوست ) شناسایی بهترین سهم در نقاط کلیدی تکنیکال دانلود کتاب های دانشگاهی pdf لیزر آرت گلس روزگار تنهای