本文已参与「新人创作礼」活动,一起开启掘金创作之路。
Trick:纯demo,心在哪里,结果就在那里
# -*- coding: utf-8 -*-
# Author : szy
# Create Date : 2019/10/17
import os
# 列出下面的方法属性
# print(dir(os))
# # 查看帮助
# help("keywords")
# # 查看import关键字如何使用
# help("import")
# # 查看模块的使用
# help("os.path")
# # 查看list如何使用
# help("list")
# # 查看字符串中find方法使用
# help("str.find")
# # 查看内置函数如何使用
# help("open")
# 字符串数字之间转换
# x = int('6')
# print(type(x))
# y = str(6)
# print(type(y))
# 字符串长度方法
# foo = 'abc'
# print(len(foo))
# print(range(len(foo)))
# open()打开文件操作 思考为什么不是6行 \n是光标下移
# poem = "\n让我们一起学习pythonPython!\n"
# f = open('D:\\PythonProject\\HelloPythonStudy\\com.bjsxt.study\\poem.txt', 'r', encoding='utf-8') # open for 'w'riting
# f.write(poem) # write text to file
# f.close() # close the file
# range() 一组数字
# print(list(range(10)))
# print(list(range(1, 10, 4)))
# print(list(range(10, -10, -4)))
# foo = 'abc'
# for i in range(len(foo)):
# # %d,用来输出十进制整数
# print(foo[i], '(%f)+%d' % (i, i))
# enumerate()
# aDict = {'host': 'earth'}
# aDict['port'] = 80
# for i, key in enumerate(aDict):
# print(i, key, aDict[key])
# type()获得对象类型
# print(type(aDict))
# print(isinstance(6, int))
# print(isinstance(aDict, dict))
# print(isinstance(aDict, list))
# import random
# print(random.uniform(1,3))
# print(random.uniform(3,1))