以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp) -- 高级功能研发区 (http://222.73.7.161/bbs/list.asp?boardid=5) ---- [原创]VBS读写注册表,全局变量,INI文件和数据库的示例 (http://222.73.7.161/bbs/dispbbs.asp?boardid=5&id=52674) |
-- 作者:z7c9 -- 发布时间:2013/6/1 12:57:54 -- [原创]VBS读写注册表,全局变量,INI文件和数据库的示例 \'测试注册表读写
\'测试全局变量读写
\'测试INI文件读写
\'测试数据库读写 [此贴子已经被作者于2013-6-1 12:58:07编辑过]
|
-- 作者:王锋 -- 发布时间:2013/6/1 17:12:23 -- 不错,学习了 |
-- 作者:solarhe2006 -- 发布时间:2013/6/9 10:09:01 -- \'测试注册表读写
\'测试全局变量读写
\'测试INI文件读写
\'测试数据库读写 |
-- 作者:z7c9 -- 发布时间:2013/6/10 9:42:11 -- c++版:
#include <QCoreApplication> //测试注册表读写 QSettings settings(path,QSettings::NativeFormat); settings.setValue("myid",12345); qDebug() << settings.value("myid").toInt(); //测试INI文件读写 QSettings settings(path,QSettings::IniFormat); settings.setValue("myid",12345); qDebug() << settings.value("myid").toInt(); //测试全局变量读写 //测试数据库读写 db.setDatabaseName("mytest.db"); if(!db.open()){ //测试CSV文件读写 if(csvFile.open(QIODevice::WriteOnly)){ if(csvFile.open(QIODevice::ReadOnly)){ int main(int argc, char *argv[]){ [此贴子已经被作者于2013/6/10 9:43:28编辑过]
|
-- 作者:z7c9 -- 发布时间: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() |
-- 作者:guotx2010 -- 发布时间:2014/11/1 17:59:15 -- PYTHON在金字塔下能用吗? |
-- 作者:z7c9 -- 发布时间:2015/5/16 22:17:36 -- AutoIt版 [此贴子已经被作者于2015/5/16 22:19:17编辑过]
|
-- 作者:z7c9 -- 发布时间:2016/1/5 0:13:53 -- Poco版: #include <iostream> #include <fstream> #include <ostream> #include <istream> #include <Poco/Util/IniFileConfiguration.h> #include <Poco/Util/PropertyFileConfiguration.h> #include <Poco/StringTokenizer.h> using namespace std; using Poco::AutoPtr; using Poco::Util::IniFileConfiguration; using Poco::Util::PropertyFileConfiguration; using Poco::StringTokenizer; //测试INI文件读取 void testINI(){ AutoPtr<IniFileConfiguration> pConf = new IniFileConfiguration("mytest.ini"); cout << pConf->getString("myid", "test") << endl; } //测试Properties文件读写 void testProperties(){ AutoPtr<PropertyFileConfiguration> pConf = new PropertyFileConfiguration("mytest.properties"); pConf->setInt("myid", 12345); pConf->save("mytest.properties"); cout << pConf->getInt("myid") << endl; } //测试CSV文件读写 void testCSV(){ ofstream ofs("mytest.csv"); ofs << "1,2,3,4,5" << endl; ifstream ifs("mytest.csv"); string line; while(getline(ifs, line)){ StringTokenizer st(line, ","); for(string s : st){ cout << s << ", "; } cout << endl; } } int main(){ testINI(); testProperties(); testCSV(); } |
-- 作者:z7c9 -- 发布时间:2016/1/5 10:45:50 -- #include <iostream> #include <sstream> #include <Poco/Timestamp.h> #include <Poco/LocalDateTime.h> #include <Poco/DateTimeFormat.h> #include <Poco/DateTimeFormatter.h> #include <Poco/DateTimeParser.h> using namespace std; using namespace Poco; int main(){ int tzd; DateTime dt; DateTimeParser::parse(DateTimeFormat::SORTABLE_FORMAT, "2015-11-21 21:44:59", dt, tzd); cout << DateTimeFormatter::format(dt, DateTimeFormat::SORTABLE_FORMAT) << endl; Timespan ts; ts.assign(60 * 5, 0); DateTime new_dt = dt + ts; cout << DateTimeFormatter::format(new_dt, DateTimeFormat::SORTABLE_FORMAT) << endl; } |
-- 作者:z7c9 -- 发布时间:2016/7/22 10:27:35 -- EasyQuant EasyStrategy CTPStrategy XSpeedStrategy FEMASSTrategy TAPStrategy EasyData CTPTickReceiver BarFactory EasyTrader EasyBacktester |