日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python中sys.argv方法的一些典型用法

發(fā)布時間:2025/3/20 python 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python中sys.argv方法的一些典型用法 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

本文整理匯總了Python中sys.argv方法的典型用法代碼示例。

示例1: weather_icons

# 需要導入模塊: import sys [as 別名] # 或者: from sys import argv [as 別名] def weather_icons():try:if argv[1] == 'loop':loop()elif argv[1] in os.listdir(folder_path):print('Drawing Image: {}'.format(argv[1]))img = Image.open(folder_path + argv[1])draw_animation(img)unicorn.off()else:help()except IndexError:help()

示例2: __init__

def __init__(self, model_nm, logfile=None, props=None,loglevel=logging.INFO):self.model_nm = model_nmself.graph = nx.Graph()if props is None:self.props = {}else:self.props = propslogfile = self.get("log_fname")self.logger = Logger(self, model_name=model_nm,logfile=logfile)self.graph.add_edge(self, self.logger)self["OS"] = platform.system()self["model"] = model_nm# process command line args and set them as properties:prop_nm = Nonefor arg in sys.argv:# the first arg (-prop) names the propertyif arg.startswith(SWITCH):prop_nm = arg.lstrip(SWITCH)# the second arg is the property valueelif prop_nm is not None:self[prop_nm] = argprop_nm = None

示例3: __init__

''' 遇到問題沒人解答?小編創(chuàng)建了一個Python學習交流QQ群:579817333 尋找有志同道合的小伙伴,互幫互助,群里還有不錯的視頻學習教程和PDF電子書! ''' def __init__(self, defaults, args):script_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]self.defaults = defaultsself.dir = self.__find_config_dir(script_name)self.parser = self.__init_configparser(script_name)global DEBUGDEBUG = self.parser.getboolean('debug', DEBUG) or args.debugglobal VERBOSEVERBOSE = self.parser.getboolean('verbose', VERBOSE) or args.verboseglobal VERIFY_SSLVERIFY_SSL = self.parser.getboolean('verify_ssl', VERIFY_SSL)global UNICODEUNICODE = self.parser.getboolean('unicode', UNICODE)if DEBUG:# Turn on some extrasglobal SAVE_PLAYLIST_FILESAVE_PLAYLIST_FILE = True

示例4: main

def main():env = os.environ.copy()# in case the PYTHONHASHSEED was not set, set to 0 to denote# that hash randomization should be disabled and# restart python for the changes to take effectif 'PYTHONHASHSEED' not in env:env['PYTHONHASHSEED'] = "0"proc = subprocess.Popen([sys.executable] + sys.argv,env=env)proc.communicate()exit(proc.returncode)# check if hash has been properly de-randomized in python 3# by comparing hash of magic tupleh = hash(eden.__magic__)assert h == eden.__magic_py2hash__ or h == eden.__magic_py3hash__, 'Unexpected hash value: "{}". Please check if python 3 hash normalization is disabled by setting shell variable PYTHONHASHSEED=0.'.format(h)# run program and exitprint("This is the magic python hash restart script.")exit(0)

示例5: ensure_lambda_helper

''' 遇到問題沒人解答?小編創(chuàng)建了一個Python學習交流QQ群:579817333 尋找有志同道合的小伙伴,互幫互助,群里還有不錯的視頻學習教程和PDF電子書! ''' def ensure_lambda_helper():awslambda = getattr(clients, "lambda")try:helper_desc = awslambda.get_function(FunctionName="aegea-dev-process_batch_event")logger.info("Using Batch helper Lambda %s", helper_desc["Configuration"]["FunctionArn"])except awslambda.exceptions.ResourceNotFoundException:logger.info("Batch helper Lambda not found, installing")import chalice.cliorig_argv = sys.argvorig_wd = os.getcwd()try:os.chdir(os.path.join(os.path.dirname(__file__), "batch_events_lambda"))sys.argv = ["chalice", "deploy", "--no-autogen-policy"]chalice.cli.main()except SystemExit:passfinally:os.chdir(orig_wd)sys.argv = orig_argv

示例6: main

def main(wf):query = sys.argv[1]baseUrl = os.getenv('baseUrl')url = baseUrl + 'user?keyword=' + querytry:result = web.get(url=url)result.raise_for_status()resp = result.textuserList = json.loads(resp)if len(userList) > 0:for item in userList:title = item['title']subtitle = item['subTitle']icon = item['icon']userId = item['userId']copyText = item['copyText']qlurl = item['url']wf.add_item(title=title, subtitle=subtitle, icon=icon, largetext=title, copytext=copyText, quicklookurl=qlurl, arg=userId, valid=True)else:wf.add_item(title='找不到聯(lián)系人…',subtitle='請重新輸入')except IOError:wf.add_item(title='請先啟動微信 & 登錄…',subtitle='并確保安裝微信小助手')wf.send_feedback()

總結

以上是生活随笔為你收集整理的Python中sys.argv方法的一些典型用法的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。