随笔分类 - Python / basic
python simple application
摘要:requests requests.get()的基本使用 # 导入 import requests # 不带参数get reponse = requests.get('url') # 带参数get headers = {'referer': 'http://xxxxxx.net/', 'user-a
阅读全文
摘要:1. 参考及测试文本 正则表达式在线测试工具,选python语言,python字符串前直接加r防止正则表达式被转义 github上找的学习资料 测试字符串(随便敲的) The fat cat sat on the mat The car parked in the garage A garage i
阅读全文
摘要:使用pip install markdown模块 只做到了分行; 表格,-,和空格还没能无缝转换 代码如下: import os import codecs import markdown def convert_markdown_to_html(markdown_file): with codec
阅读全文
摘要:安装chardet pip install chardet 获得文本文档编码类型 import chardet from chardet.universaldetector import UniversalDetector def GetEncoding(file_path): with open(
阅读全文
摘要:1. 新建json文件 打开记事本,重命名为.json后缀 使用的样例如下,注意看json文件格式: { "server":{ "host": "example.com", "port": 443, "protocol": "https" }, "authentication":{ "usernam
阅读全文
摘要:十进制转二进制,bin() decimal=10 binary=bin(deciaml) print(binary) 十进制转八进制,oct() decimal=10 octal=oct(deciaml) print(octal) 十进制转十六进制,hex() # case1 decimal=10
阅读全文
摘要:OS提供许多和操作系统交互的功能,允许访问文件,目录,进程,环境变量等。 导入模块,import os 获取当前工作目录,os.getcwd() current_dir=os.getcwd() print("当前工作目录:",current_dir) >>> 当前工作目录: C:\Users\wuy
阅读全文
摘要:为了本地备份随笔内容。 用到requests下载图片和re解析markdown文本 代码如下: import re import os import requests # markdown文件的路径,绝对路径 markdown_file_path = "C:\\Users\\wuyucun\\Des
阅读全文