专栏名称: 小小的python学习社
分享数据干货,热爱研究python各种应用。以python为核心,文章涵盖各种编程语言科普及资料等
今天看啥  ›  专栏  ›  小小的python学习社

100个python的基本语法知识【下】

小小的python学习社  · 公众号  ·  · 2025-03-16 17:00
    

文章预览

50. 压缩文件: import  zipfile with  zipfile. ZipFile ( "file.zip" ,  "r" )  as   zip_ref :     zip_ref. extractall ( "extracted" ) 51. 数据库操作: import   sqlite3 conn   =  sqlite3.connect( "my_database.db" ) cursor = conn.cursor() cursor.execute( "CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, name TEXT)" ) conn.commit() conn.close() 52. 网络请求: import   requests response   =  requests.get( "https://www.example.com" ) 53. 多线程: import  threading def  my_thread () :     print( "Thread running" ) thread = threading. Thread (target=my_thread) thread. start () thread. join () 54. 多进程: import multiprocessing def my_process():      print ( "Process running" ) process = multiprocessing. Process (target=my_process) process. start () process. join () 55. 进程池: from  multiprocessing  import  Pool def   my_function ( x ):      return  x*x with  Pool( 5 )  as  p:      print (p. map (my_function, [ 1 ,  2 ,  ………………………………

原文地址:访问原文地址
快照地址: 访问文章快照
总结与预览地址:访问总结与预览