欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。


金字塔客服中心 - 专业程序化交易软件提供商金字塔软件高级功能研发区 → [原创]VBS读写注册表,全局变量,INI文件和数据库的示例

   

欢迎使用金字塔普通技术服务论坛,您可以在相关区域发表技术支持贴。
我司技术服务人员将优先处理 VIP客服论坛 服务贴,普通区问题处理速度慢,请耐心等待。谢谢您对我们的支持与理解。    


  共有12026人关注过本帖平板打印复制链接

主题:[原创]VBS读写注册表,全局变量,INI文件和数据库的示例

帅哥哟,离线,有人找我吗?
z7c9
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:小飞侠 帖子:1882 积分:3310 威望:0 精华:15 注册:2010/3/15 13:11:56
  发帖心情 Post By:2014/11/1 12:03:36 [只看该作者]

Python版:

#测试注册表读写
def testRegistry():
    import winreg
    key = winreg.CreateKey(winreg.HKEY_CURRENT_USER,r"software\weisoft\金字塔\settings")
    winreg.SetValueEx(key,"id",0,winreg.REG_DWORD,123)
    print(winreg.QueryValueEx(key,"id")[0])

#测试INI文件读写
def testINI():
    import configparser
    config = configparser.ConfigParser()
    config.add_section("settings")
    config.set("settings","myid","12345")
    config.write(open("mysettings.ini","w"))
    print(config.get("settings","myid"))

#测试CSV文件读写
def testCSV():
    import csv
    with open("test.csv","w") as csvfile:
        csvwriter = csv.writer(csvfile)
        csvwriter.writerow(['1','2','3','4','5'])

    with open("test.csv","r") as csvfile:
        csvreader = csv.reader(csvfile)
        for row in csvreader:
            print(row)

#测试数据库读写
def testDatabase():
    import sqlite3
    conn = sqlite3.connect("test.db")
    c = conn.cursor()
    c.execute("""create table main(id varchar)""")
    c.execute("""insert into main values(12345)""")
    rec = c.execute("""select * from main""")
    print(c.fetchall())

testRegistry()
testINI()
testCSV()
testDatabase()


 回到顶部
总数 11 1 2 下一页