|| 和&& 用法:
逻辑或,只有||前面的执行不成功 才会执行后面的;
逻辑与,只有&&前面的执行成功,才会执行后面的。
python -c: 可以在命令行中执行 python 代码;
python -m xxx.py:把xxx.py文件当做模块启动
# 遍历文件夹中文件代码段
import os
infile = open("/home/ubuntu/work2/DW/lilu.txt","w")
for root,dirs,files in os.walk("/media/ubuntu/Elements/lilu"):
infile.write(root+'n')
infile.close()
# 自动打开谷歌常用网址
import webbrowser
first = True
chromePath = '/usr/bin/google-chrome'
URLS = ("https://www.baidu.com/","https://sso.huaqin.com/login","https://www.csdn.net/")
for url in URLS:
if first:
webbrowser.get(chromePath).open(url)
first = False
else:
webbrowser.open(url,new=2) # new=0,url会在同一个浏览器窗口下打开;1, 会打开一个新的窗口;2, 会打开一个新的浏览器标签页;
# python 打包可执行文件 dist文件夹下 pip install pyinstaller pyinstaller -F 文件名.py三:终端指令
grep -q “OK” : 静默模式,grep不会输入任何信息,无论是否匹配到指定的字符串,都不会输出任何信息,所以,我们需要配合”echo $?”命令,查看命令的执行状态,如果返回值为0,证明上一条grep命令匹配到了指定的字符串,如果返回值为1,则证明上一条grep命令没有匹配到指定的字符串;



