我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用os.makedir()。
def pre_write(self): settings = utils.get_settings('ssh') apt_update(fatal=True) apt_install(settings['client']['package']) if not os.path.exists('/etc/ssh'): os.makedir('/etc/ssh') # NOTE: don't recurse utils.ensure_permissions('/etc/ssh', 'root', 'root', 0o0755, maxdepth=0)
def pre_write(self): settings = utils.get_settings('ssh') apt_update(fatal=True) apt_install(settings['server']['package']) if not os.path.exists('/etc/ssh'): os.makedir('/etc/ssh') # NOTE: don't recurse utils.ensure_permissions('/etc/ssh', 'root', 'root', 0o0755, maxdepth=0)
def add_points(message): """ Every time someone sends a message, they gain one point. This is because any time based ones would result in mobile users having the same amount of each, due to idling. """ split_message = message.content.split() message.author.name = message.author.name.lower() points = load_points(message, message.author.name) message_amount = messages.load_messages(message, message.author.name) non_trigger = ["!points","!roulette","!userpoints","!givepoints","!barryroulette","!rps","!rockpaperscissors"] non_message_trigger = ["!usermessages","!messages"] if message.author.name not in message_amount: message_amount[message.author.name] = 0 elif len(split_message) == 0 or split_message[0] not in non_message_trigger: message_amount[message.author.name] += 1 if message.author.name not in points: points[message.author.name] = 0 elif len(split_message) == 0 or split_message[0] not in non_trigger: points[message.author.name] += 1 try: pickle.dump(points, open("{0}/{0}_points.txt".format(str(message.server)),"wb")) except FileNotFoundError: try: os.makedir("{}".format(message.server)) except FileExistsError: temp_points = open("{0}/{0}_points.txt".format(str(message.server)),"w") temp_points.close() pickle.dump(points, open("{0}/{0}_points.txt".format(str(message.server)),"wb")) pickle.dump(message_amount, open("{0}/{0}_messages.txt".format(str(message.server)),"wb")) return True #Sets emotes in points, is its own function due to me using it twice.