zoukankan      html  css  js  c++  java
  • python with 操作文件

    with 管理上下文可以自动关闭文件:with open('h.log') as f:f.write('ss')

    def show():
    print('123')
    yield
    print('456')
    with show():
    print('999')

    这样就可以通过with管理上下文了,即执行结果为,123 999 456 ,也就是所可以在456那写文件关闭;这样就不会影响show函数和在show之后再次操作相关操作,如文件操作;可以让自己再show中打开文件,在程序结束之后才关闭文件,而不是函数结束之后关闭文件;
    线程池:需要用到这个:计算有多少线程在用这个线程池;
  • 相关阅读:
    【poj1655】Balancing Act
    yargs.js用法
    8、typescript
    7、typescript
    6、typescript
    5、typescript
    4、typescript
    3、typescript
    2、typescript
    1、typescript
  • 原文地址:https://www.cnblogs.com/bluesl/p/9022072.html
Copyright © 2011-2022 走看看