Learn to program with Minecraft and Python

http://www.broadview.com.cn/book/156

0.1 https://www.nostarch.com/pythonwithminecraft/
1.1 https://www.nostarch.com/pythonwithminecraft/
1.2 https://minecraft.net/
1.3 https://minecraft.net/download
1.4 http://www.python.org/downloads/
1.5 http://www.java.com/en/download/
1.6 http://www.java.com/en/ download/help/path.xml
1.7 https://www.nostarch.com/pythonwithminecraft/
1.8 https://minecraft.net/download
1.9 https://www.python.org/downloads/mac-osx/
1.10 http://www.oracle.com/technetwork/java/javase/downloads/index.html
1.11 https://www.nostarch.com/pythonwithminecraft/
1.12 http://www.raspberrypi.org/
10.1 https://www.nostarch.com/pythonwithminecraft/
11.1 http://pypi.python.org/
11.2 http://flask.pocoo.org/docs/0.10/tutorial/
12.1 https://www.nostarch.com/pythonwithminecraft/

Troublshooting

https://nostarch.com/minecrafthelp
The book Learn to Program with Minecraft requires Minecraft 1.8 or 1.9, Python 3.6 or newer and Java 8 or newer. If you're having difficulty getting your environment set up, software versions are the most likely problem. Follow the instructions on this page to check that you are using the correct versions of Minecraft, Python, and Java.

If you've confirmed that you have the correct versions and you're getting other errors, refer to the later sections in this document (linked below).

Pick the Right Minecraft Version
Am I Using the Right Version of Python?
Am I Using the Right Version of Java?
What If I Have Two Versions of Python on My Computer?
Start_Server, File Cannot Be Found (For Windows)
Connection Refused Error (For Mac)
Nothing Happens After I Click Install_API (For Windows)
Permissions Error When Installing API (For Mac)
Unicode Decode Error (For Windows)
I Got a Different Error!

Unfortunately, we do not have any dedicated Python programmers on our team, so we are unable to troubleshoot more complex errors. Sorry for the inconvenience!

Pick the Right Minecraft Version
Purchase the standard Minecraft version from minecraft.net to follow along with the book. You must have Java Edition for Windows and OSX or Pi Edition for the Raspberry Pi.

Please know that Minecraft Windows 10 Edition, Minecraft for Xbox, Minecraft: Education Edition, and Minecraft: Pocket Edition are not compatible with the book.

In order to use your Spigot server, your Minecraft version needs to match the Spigot version exactly. But new versions of Minecraft come out all the time, so if you update Minecraft, Spigot won’t work with the new version anymore. In order to make your Spigot and Minecraft versions match, you can set up a profile.

When you set up a profile, you tell Minecraft that you only want to use the version of the game that will work with the version of the server that you are using. In other words, a profile allows you to continue using the same server even when newer versions of Minecraft are released.

Once you set up a profile, you should be able to use our book’s coding directions and you'll know one more of Minecraft’s secrets, and will be further along on your journey to become a Minecraft Master!

Let’s get started.

For Windows

You’ll need to set up a profile to make sure Spigot and Minecraft are always running the same version. To start Spigot, follow these steps:

Step 1. Go to your Minecraft Python folder and open your Minecraft Tools folder.
Step 2. In the Minecraft Tools folder, double-click the Start_Server file. If you get a message asking whether you want to allow access, click Allow.
Step 3. A window will appear and begin to set up the server. If you see a message that says the server is out of date, don’t worry; you don’t need to update the server for it to work.
Step 4. Once the setup is finished, scroll to the top of the text in the window. Near the top (around the third or fourth line), you should see text saying Starting minecraft server version x.x.x. For example, 1.16.3.
Step 5. Make a note of the version number shown on your screen, and keep this window open.

Now that you know which server version you’re using, you can set up the game profile:

Step 1. Open the Minecraft launcher, but don’t click the green PLAY button quite yet (make sure you leave the server window open when you do this).
Step 2. At the top-right of the Minecraft launcher, click the menu button (which looks like three parallel lines), then click the Launch Options button. This will allow you to access the profile editor.
Step 3. Click the Add New button to create a new configuration.
Step 4. In the Name field, type Learn to Program with Minecraft.
Step 5. In the Version drop-down menu, select the version of the server that you’re using. For example, version 1.16.3.
Step 6. Click the Save button. Your profile has now been set up. Click the central Minecraft logo to return to the screen with the green PLAY button.

From now on, every time you want to use Minecraft with this book, click the arrow next to the Minecraft launcher’s start button. Select the Learn to Program with Minecraft option to use the correct version for the server. You can swap back to the latest version of Minecraft at any time by changing this drop-down menu to the Latest Release option. Once you have selected the correct version, click PLAY!

For Mac

You’ll need to set up a profile to make sure Spigot and Minecraft are always running the same version. To start Spigot, follow these steps:

Step 1. Go to your MinecraftPython folder and open your MinecraftTools folder.
Step 2. In the MinecraftTools folder, CONTROL-click the Start_Server file and select Open. (If you get an error message, go to System Preferences and then to Security and Privacy and click Open Anyway.)
Step 3. Once the setup is finished, scroll to the top of the text in the window. Near the top (around the third or fourth line), you should see text saying Starting minecraft server version x.x.x. For example, version 1.16.3.
Step 4. Make a note of the version number shown on your screen, and keep this window open.

Now that you know which server version you’re using, you can set up the game profile:

Step 1. Open the Minecraft launcher, but don’t click the green PLAY button quite yet.
Step 2. In the top-right corner of the Minecraft launcher, click the menu button (which looks like three parallel lines), then click the Launch Options button. This will allow you to access the profile editor. Click the Add New button to create a new configuration.
Step 3. In the Name field, type Learn to Program with Minecraft.
Step 4. In the Version drop-down menu, select the version of the server that you’re using. For example, version 1.16.3.
Step 5. Click the Save button. Your profile has now been set up. Click the X in the upper-right corner, then click the central Minecraft logo to return to the screen with the green PLAY button.

From now on, every time you want to use Minecraft with this book, select the Learn to Program with Minecraft option in the drop-down menu to the right of the green PLAY button. You can swap back to the latest version of Minecraft at any time by changing this drop-down menu to the Latest Release option.

Am I Using the Right Version of Python?
Follow these steps to make sure you're running Python 3.6 or newer.

Note: If you find that you have both Python 2 and Python 3 installed, you should uninstall Python 2—or follow the instructions in “What If I Have Two Versions of Python on My Computer?” below.

For Windows

The simplest way to confirm you’ve gotten the right version of Python is to go to the Start menu, then search for Python. If you don’t see a search box, you can just start typing Python to search. This will show you every version of Python that you have installed on your machine. The Python version number might be part of the name that shows up in the Start menu; if not, open IDLE and the version number will be displayed in the shell.

If you don’t have version 3.6 or newer, you’ll need to install the updated version. Follow the steps in “Installing Python” in the book.

For Mac

Step 1. Open Finder and search for Terminal. Click Terminal to open it.
Step 2. At the Terminal prompt, enter Python -V (note that the V is uppercase).
Step 3. You will see the Python version number—if it's anything older than 3.6, you'll need to install an updated version. Follow the steps in Chapter 1 to install Python version 3.6.

Am I Using the Right Version of Java?
Follow these steps to make sure you're running Java 8 or newer.

For Windows

You should be able to see all the installed programs in the Windows Start menu, including Java. The simplest way determine which version you have installed is to do the following:
Step 1. Go to the Start menu.
Step 2. Choose All Programs.
Step 3. Find the Java folder and click About Java.

You can also test the version of Java by using this method:
Step 1. Open the Start menu, search for cmd, and open the command prompt.
Step 2. Run the command java -version. You will see a message that says something like java version "1.8.0_72". The version of Java that you are using is the number after the first dot, which is version 8 in our example message. If your version is older than 8 (or if Java isn’t installed at all!), you’ll need to update or install Java. To do so, follow the installation instructions in Chapter 1.

For Mac

Step 1. Open Finder and search for Terminal. Click Terminal to open it.
Step 2. At the Terminal prompt, type java -version and press RETURN.
Step 3. You will see a message that says something like java version "1.8.0_72". The version of Java that you are using is the number after the first dot, in this case version 8. If your version is older than 8, you'll need to update Java. To do so, follow the installation instructions in Chapter 1.

What If I Have Two Versions of Python on My Computer?
If you want to have both Python 3 and an older version of Python installed, and if you have an older version of the Install_API file, you need to modify the file to specify that it should use Python 3 rather than the older version.

The Minecraft Python API will work with older versions of Python, but you must use Python 3 if you want to run all the code examples from this book—otherwise you’ll get an error if you try to use the print() function and a few other Python things. But you can still keep another, older version of Python on your computer if you want to.

Install the Minecraft Python API by following the Windows or Mac instructions in the following sections. Once you’ve installed the API, you’ll need to make sure that you use the correct version of IDLE. Make sure you use IDLE 3 when writing and running code—otherwise the programs from this book will not work.

For Windows

If you have the older version of the Install_API file, then you’ll need to modify it. To modify the In-stall_API file, follow these steps:

Step 1. Open the Minecraft Tools folder and find the Install_API file.
Step 2. Right-click the Install_API file and select Edit.
Step 3. Once the file opens, find the line that begins with this:

python -m pip install minecraftPythonAPI.zip

Step 4. Edit the line by changing python to python3 so that the line looks like this:

py -3 -m pip install minecraftPythonAPI.zip

Step 5. Save the file and close it.
Step 6. Double-click the Install_API file to install the Minecraft Python API.

For Mac

If you have the older version of the Install_API file, then you’ll need to modify it. To modify the In-stall_API file, follow these steps:

Step 1. Open the Minecraft Tools folder and find the Install_API file.
Step 2. Control-click the Install_API file and select Edit.
Step 3. Once the file opens, find the line that begins with this:

python -m pip install minecraftPythonAPI.zip

Step 4. If you can’t find that line, then you already have the new file and don’t need to do anything else. Otherwise, edit the line by changing python to python3 so that the line looks like this:
python3 -m pip install minecraftPythonAPI.zip

Step 5. Save the file and close it.
Step 6. Double-click the Install_API file to install the Minecraft Python API.

Start_Server, File Cannot Be Found (For Windows)
When you click on the Start_Server file you might see a window saying “Windows cannot find 'C:\Users\Frank\Documents'” or something similar.

To work around this issue, open the server folder and double click on the start.bat file. The server should start normally. Every time you need to start the server in the future repeat these steps.

Alternatively, download the latest version of the book's setup files, Minecraft Tools, linked on the book's web page.

Connection Refused Error (For Mac)
In Python, after typing the line mc = Minecraft.create(), you might get an error message like this:

ConnectionRefusedError: [Errno 61] Connection refused

or a similar error like this:

ConnectionRefusedError: [Errno 10061] No connection could be made because the target machine actively refused it.

This error is most frequently caused by an out-of-date version of Java installed on your computer. In order to fix this issue, follow the Java installation instructions in Chapter 1.

If you still get this error after reinstalling Java, your Mac might be using an old version of Java only on the command line. To fix this issue, do the following:

Step 1. Click the search icon on the top-right corner of your screen.
Step 2. In the search box, enter Java Preferences.
Step 3. When the preferences box opens, make sure that only the Java 8 checkbox is ticked.

After you have changed these preferences, the problem should be resolved. However, if you still have this issue, uninstall older versions of Java and then reinstall Java 8.

Nothing Happens After I Click on Install_API (For Windows)
When you run the Install_API file during step 5 of “Installing the Minecraft Python API and Spigot” (page 6), you might see a black window pop up.

If you see a window like this, you might be experiencing a bug with pip, which is used to install the API. To work around this, you need to install the Minecraft Python API via the command line. Follow these steps:

Step 1. Open the Minecraft Tools folder. You should see the minecraftPythonAPI.zip file.
Step 2. In the file browser, click the address bar to highlight it, then copy the text (right-click and select Copy, or press CTRL-C). The address should look something like this:

C:\Users\user\Minecraft Python\Minecraft Tools

Step 3. Click the Start menu and search for PowerShell. Click PowerShell to open it.
Step 4. At the PowerShell prompt, type cd and then right-click to paste the address of your Minecraft Tools folder.
Step 5. Add single quotation marks around the text you just pasted. The line should look something like this:

cd 'C:\Users\user\Minecraft Python\Minecraft Tools'

Step 6. Press ENTER. Now you can run commands in PowerShell using the contents of the Minecraft Tools folder.
Step 7. On the next line, type the following command to install the API:

python -m pip install minecraftPythonAPI.zip

Step 8. Press ENTER. The Python API should now be installed correctly.

Permissions Error When Installing API (For Mac)
During step 8 of “Installing the Minecraft Python API and Spigot” in Chapter 1, you might get this error:

The directory '/Users/YourUserName/Library/Caches/pip/http' or its parent
directory is not owned by the current user and the cache has been
disabled. Please check the permissions and owner of that directory. If
executing pip with sudo, you may want sudo's -H flag.

Check all the folders that the Install_API file is inside of and remove any spaces from the folder names. To do this, follow these steps:

Step 1. Control-click the icon of the folder with a space in the name.
Step 2. From the pop-up menu, select Rename, then remove the space from the folder’s name. Note that you should not have to do this with the hard drive itself (Macintosh HD)!

Once you have done this, try running the Install_API file again.
On some Macs, you might still get an error—however, the API has still installed correctly. If you see the following line, the API has installed correctly and you can ignore the error message:

Requirement already satisfied (use -–upgrade to upgrade): py3minepi…

Unicode Decode Error (For Windows)
When you run the Install_API file during step 5 of “Installing the Minecraft Python API and Spigot” in Chapter 1, you might get this error:

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc0 in position 44: invalid start byte

Your Windows system may be using an encoding method that's different from the one Python assumes. Follow these steps:

Step 1. Navigate to

'C:\Users\user\AppData\Local\Programs\Python\Python36\Lib\site-packages\pip\compat'

This path is for those running Python 3.6 and will differ slightly for other versions.

Step 2. Open init.py in a text editor, and change line 75 to this:

return s.decode('cp949')

Making this change and saving the file should resolve the problem.

I Got a Different Error!
Unfortunately, we do not have a dedicated Python programmer on our team, so we are unable to troubleshoot more complicated issues on your behalf at this time. If you get an error that isn't listed on this page, we would encourage you to search for the error online. We're sorry for the inconvenience, but thank you for your understanding!

为屠龙刀找龙

背景

这两天,依图IPO中止了,尽管他们出面澄清是自己主动申请,而且强调是“中止”不是“终止”,但是面对一夜暴富的机会,谁会中止呢?阿桑奇也没止住。

冲突

最近吧,遇到一个问题,要为AI智能平台找到应用的场景,实际就是要找到这个产品的价值。

问题

市场是最公平的,你压货、对倒,最终都会被市场打出原形,谁的钱是平白无故给你呢?只有政府这个傻冒吧。

答案

政府也不傻,这类高科技独角兽,在大G面前,就是痰盂、夜壶,想端出来的时候,就端一下,
那么,就做一个集成商吧,被另外一个集成商当作痰盂,来,单一来源采购吧。

找不到龙,what's different between 菜刀&屠龙刀?

查找wordpress数据库密码

查找mariadb数据库密码

查找wp-config.php这个文件,找到password就可以

# find -name wp-config.php
./var/www/html/wordpress/wp-config.php
# vi ./var/www/html/wordpress/wp-config.php

while用法

When condition is true, which include the result(true or false) of operator like 'not equal(!=)' or 'less than(<)'or 'greater than or equal to(>=)', the statement after colon will be executed.

When we use function input, the function will return string type, so if we want compare result with number, we can use str() to convert number to string and int() to convert string to int.

message = input('if you input 0,then everthing is over')
i = 1
while message != str(0) and i <=10 :
    print(str(i)+' '+message)
    i +=1

cv2.destroyAllWindows()出错

Jupyter's error can not be solved immediately, however when I run the script in terminal, error message is here:

.../Study/learningOC[15:52]python3 cameraFrames.py
Showing camera feed. Click window or press any key to stop.
Traceback (most recent call last):
  File "...Study/learningOC/cameraFrames.py", line 19, in <module>
    cv2.destroyAllWindows('MyWindow')
SystemError: <built-in function destroyAllWindows> returned NULL without setting an error

Therefore I check the demo code:

import cv2

clicked = False
def onMouse(event, x, y, flags, param):
    global clicked
    if event == cv2.EVENT_LBUTTONUP:
        clicked = True

cameraCapture = cv2.VideoCapture(0)
cv2.namedWindow('MyWindow')
cv2.setMouseCallback('MyWindow', onMouse)

print('Showing camera feed. Click window or press any key to stop.')
success, frame = cameraCapture.read()
while success and cv2.waitKey(1) == -1 and not clicked:
    cv2.imshow('MyWindow',frame)
    success, frame = cameraCapture.read()

#cv2.destroyAllWindows('MyWindow')
cv2.destroyAllWindows()
cameraCapture.release()

After deleting the arguments 'MyWidows' in destroyAllWindows, the script is running well.

李骥德

1937年12月

一九三七年十二月十二日,是“西安事变”一周年纪念日。那天下午,日寇飞机轰炸西安,傍晚,解除警报后,警察跑到西安二中来捣乱,造谣说,日寇飞机轰炸时,二中的院子里有人给敌机打信号。以此为借口,无事生非,大肆搜查。不巧从学生党员李自俊(李骥德)同志身上,“搜出”了一个安吴青训班编写的《抗日民族统一战线讲授提纲》,说这就是证据,要强行把李自俊同志拉走。我们同他们辩论,并且把李自俊同志从警察手中抢了过来。抢的中间,警察开枪打伤了学生张儒。这件事引起了公愤。省委曾发出通知,要求各校发动群众,揭露国民党政府纵容警察,横行霸道,胡作非为,迫害学生的罪行。各学校立即响应,一时间西安古城风云突变,支援的浪潮席卷全城。这才迫使国民党反动当局不得不低头认错。十二月十九日西安各报都刊登了警察局认错启事,说警察局长杭毅严重失职,记大过一次;并由杭毅亲自到二中向全体师生认错,保证以后不发生类似事件。斗争取得了胜利,对国民党反动当局的嚣张气焰也是一次沉重的打击。

1943

打入三青团
李骥德,系陕西礼泉县人。1937年3月,他在西安二中上学时,参加民先队。5月间,民先队介绍他去安吴青训班学习,参加中共陕西省委干部训练班,结业后被派回西安一中继续上学,参加一中党支部,担任组织委员。第二年,他从一中毕业,考入新成立的西安兴国中学高中班,担任该校地下党总支委员。1940年秋,又考入国民党陕西政治学院政治系,1941年下半年学院改为陕西省商业专科学校,李骥德在该校学习政治法律两年时间,1943年夏毕业。

这年初,为贯彻中共中央“精兵简政”的指示精神,中共陕西省委和陕甘宁边区、关中分区合并,成立中共关中地委,张德生任地委书记,汪锋任副书记兼统战部长,同时兼任关中分区保安处处长。开始整风和肃奸斗争。基本停止了派干部到国统区联系工作,但是张德生和汪锋还是决定派李骥德打入国民党三青团内部,并由汪锋主管负责打入工作。汪锋派交通员张仁民前往西安传达这一指示,并决定把李骥德的组织关系放在兴国中学,就地加入三青团。李骥德接受任务后,为了站稳脚跟,他采用汪锋所讲的“巴、拉、压”的办法,利用工作关系,通过三青团商专分团部书记刘积智的介绍,结识了三青团陕西支团部组训组组长陈忠经。陈是江苏仪征人,任过北大学生会主席,名噪一时的学生领袖,参加过“一二·九”运动,北平沦陷后即随北京大学流亡湖南,参加胡宗南组织的湖南青年战地服务团,后辗转西安,还当上三青团首任西京分团书记,胡宗南很信任他。新中国成立后,曾任中联部副部长。陈和熊向晖、申健被誉为中共情报战线“后三杰”。

李骥德加入三青团后,打入三青团陕西支团部陈忠经的组训组里工作。陈忠经曾对李骥德说:“你的情况我了解,你来后,对工作有好处。有什么困难,尽可以告诉我。” ①

李骥德进入陈忠经组训组之初,搞一些抄抄写写的事情,两个月后,感到接触不到敌人的机密,更谈不上掩护同志,便同商专中共总支书记王世俊商量,最好力争到一个县去工作,这样可以掌握一个地方或一个单位的实权,独当一面地开展工作。商量决定后,李骥德便向陈忠经提出下基层去锻炼一段时间。

没料到陈忠经答应得很爽快:“好哇!年轻人有朝气,初生牛犊不怕虎,会有出息的。不过,我得和杨尔瑛研究一下再告诉你。”杨尔瑛系陕西榆林人,时任三青团陕西支团部干事长。

不几天,陈忠经便告诉李骥德:“我们同意你的要求。”并问道,“你愿意到哪儿去?”李骥德略加思索后回答:“我是关中人,对关中风土人情比较了解,最好就到关中一个县去,而且我想离你近一些,因为我年轻,没经验,工作中遇到困难,也好便于向你请示,听从你的指教。”

陈忠经一听,笑了笑说:“没看出来,你还是个善于言辞的人呢,那你就到眉县去吧,行吗?”

“眉县(三青)团的状况如何?”李骥德问。

“眉县尚未建立县一级团的组织,只有团的基层组织,而且是由三青团周至县分团部兼管,周至也没有兼管好,急需要建立眉县分团部。”陈忠经如实介绍着。

“让我考虑一下吧!”李骥德边答应边拖延时间。因为他还未向党总支和省委请示。

然后,李骥德将与陈忠经的谈话内容一一报告党总支和省委,汪锋又通过交通员张仁民转告他,省委同意打入的意见。李骥德还和党总支书记王世俊进行了一番分析评估,取得一致意见:认为陕西关中只有东府的朝邑和西府的眉县尚未建立县一级三青团机构,朝邑太小,韩城、大荔的反动势力正千方百计地打入朝邑,不利于开展工作,于是李骥德便尊重了陈忠经的意见,找到陈忠经,表示听从他的调遣,前往眉县。

当时,李骥德虽然不知道陈忠经也是打入三青团的秘密共产党员,但总觉得他的举止谈吐不像是国民党和三青团的党棍团棍,不打官腔,既不吹捧国民党、三青团,也不辱骂共产党。为了长期隐蔽埋伏下去,李骥德按照汪锋、张德生多次强调的“广交朋友”、“巧于伪装”、“内红外白”等反特斗争工作经验,尽量与各方面人士和势力搞好关系。

当时三青团在陕西正处于发展时期,李骥德到眉县上任一段时间后,发现国民党眉县党部书记长蒙文卿是个被“赵公元帅”迷住心窍的人,他经常利用职权向银行贷款,然后转借,进行高利盘剥,利用盘剥的不义之财,在家乡泾阳买地置田,在西安购房经营商号。李骥德和别人一样,对蒙图财谋钱的恶劣行径只是睁一只眼,闭一只眼,井水不犯河水,不去计较,免得发生矛盾,关系相处比较融洽。李骥德在眉县干了五年多时间,换了四任县长,除第一任县长是个国民党政客,CC分子,相处时间很短,此县长就调往河南,与其余三任县长相处也比较随和,工作上得到他们的支持。

李骥德到眉县,打入敌人营垒五个年头,经历了站得住、站得稳、钻得深三部曲,从三青团眉县分团书记、干事长,再至帼民党眉县党部书记长,表面上是“步步高升”,实际上是“层层深钻”,“荫蔽埋伏”。由于掌握了国民党眉县党团最高权力,就为党的工作开辟了阵地。李骥德利用合法身份和手中权力,把一批批进步知识分子或共产党员,安排到中小学任教,控制了教育阵地,团结了广大师生和青年知识分子。他安排廉洁之为金渠镇中心小学校长,安排中共眉县县委宣传部长钮永哲先为三青团眉县分团部书记长,后为眉县简易师范学校校长,安排董锡钧到眉县中学主持工作,安排宋建元为渭北乡中心小学校长,安排赵宏勋和从咸阳来的地下党员魏治均到眉县中学去任教。

李骥德隐蔽埋伏在眉县的几年,利用各种机会,通过各种途径,搜集到敌人不同时期的政治、经济、军事、党务等情报,汇报给省委。在抗日战争进入最艰难的岁月,由于国民党对边区的封锁,从中央到省委一直到基层组织,活动经费十分拮据,延安开展了大生产运动。1944年冬,李骥德回马栏向省委汇报工作,汪锋、张德生建议李骥德想办法利用国民党的钱为共产党办事情,也可以在眉县搞点生产,支助一下省委和边区。李骥德按照汪锋、张德生建议,着手从四个渠道开辟财源,筹集经费。一是利用敌人党团名义,从国民党的银行贷款,再把这些款子转贷给私人,从中获利。二是利用农村二三月青黄不接时机,贷款给农民,夏收后以此抵债,但不搞高利盘剥。三是租农民土地,雇人种植烟叶,销售盈利。四是当粮价走低,设法多购进一些,粮价抬高上涨,再抛售出去。通过以上几种渠道筹集到一批经费,帮助省委渡过困难时期,解决了大问题,同时这一套做法,也无形中掩护了自己。

1946年夏

夏初 中共陕西省工委派余政到眉县协助地下党员李骥德工作。李以三青团眉县团部干事长的身份为掩护将余政安排在三青团部,余政一面协助李骥德搜集敌人的情报,一面考察恢复原地下党员的组织关系,为建立中共眉县工委做准备。

1946年冬

马德被捕英勇就义

1946年冬,眉县地下党员庞××,被国民党县政府指令庞家所在地的齐镇乡公所逮捕,押送县看守所。在此以前,眉县地下党组织处于“睡眠”状态。后来李骥德根据党的指示,做了眉县三青团领导人,由省工委直接联系。1946年夏、秋,陕西工委又从陕甘宁边区派回庞和马德(任县委书记)、余正(任县委副书记)来眉县恢复党的组织,开展工作。马在横渠镇武家堡一带活动,余隐蔽在三青团团部内任职。庞被捕后供出他的身份、任务和拟与马德接头的地点,眉县党组织面临严重破坏的危险。

在此紧急关头,李骥德为挽救危局,即以三青团领导人的身份派人阅卷。得知庞的供词,后又亲自提审,拟诱导翻供而未成。最后提示庞的远门亲戚、县参议长出头保释出狱,才防止了事态扩大。后来马德、余正向省委汇报工作回程中,路经耀县小丘地区时被敌逮捕,英勇牺牲。此后潜伏在敌党、政、教育系统的党员和在农村活动的党员互相配合,开展工作。西安解放前夕,还组织武装人员袭击撤退的敌军,收缴武器弹药,配合我军的胜利攻势。

1947年10月

10月,本县国民党部、三青团部合并为国民党县党部,李骥德任书记长。

1949年5月

5月,在槐芽中戏楼场演戏时,简师学生与秦岭守备区陈义海营发生冲突,后以兵方向学生赔情道歉和送20个银元赔偿而告结。10日,钟仁亮率县国民兵大队保警三中队起义。中旬初,新县委组成,西北局任命杨雨亭为书记。16日,地下党员武彦昌率秦岭守备区三团一营,在青化烟囱沟至猴娃桥一带,与胡宗南逃军激战一小时。20日傍晚,该营复在原地与敌激战一小时。是日地下党员赵振华组织地下团员以武装赶走常兴粮站管理人员,接管了敌未运走的20多万斤面粉和大米。21日,赵振华等将面粉和大米转交部队,获“解放大西北纪念章”一枚。同日,县党政军要员弃城逃至金渠镇公所,夕阳西下时返回县城。当晚深夜(实为次日凌晨二时许),南渡渭河的西野二军六师前卫营解放了郿县城,俘敌县长程新三以下30余人。22日,地下党员李金泉率一支武装,在鹦鸽石嘴崖伏击南逃之敌。是日,二军六师政委曾涤派师部民运科长杨格代理郿县人民政府县长,并任命钟仁亮为眉县游击大队长,李金泉、肖富州为正副指导员。同日,地下党叫李骥德约会了曾涤政委。24日,六师主力南渡渭河,并向斜峪关之敌军发起猛烈攻击,解放了郿县全境。25日,敌沿斜峪关分三路向南溃逃。钟仁亮率保警三中队,在寨子城高地截击敌人,毙伤敌军100余人,战斗结束后即宣布起义。月底,敌36军、65军沿渭河南岸向东推进,欲图西安。

1951年底

千阳县在国家工作人员中开展了反贪污、反浪费、反官僚主义的“三反”运动。“三反”当时称增产节约运动。县长李骥德任主任,监委会主任康守志任副主任。

1963年四月二十八日

国务院公报
国务院命令,一九六三年四月十三日国务院全体会议第一三零次会议通过,任命:
李骥德为陕西省人民委员会办公厅主任

国务院总理 周恩来


Screen Shot 2021-03-09 at 20.29.07

1967年

七十三号
“七十三号”成为“军事监护所”
  1967年,陕西文革造反组织派别间的纷争如火如荼,无论是造反较早的以西安交大为首的东派,还是以干部子弟居多的西军电、西工大为主的西派,都在以革命的名义进一步深入夺权。西安各红卫兵组织已经不满足于揪斗陕西的“走资派”,决心再抓名气更大、地位更高的“走资派”。1月4日,西北大学一派红卫兵组织奔赴洛阳矿山机械厂,将原国务院副总理习仲勋揪回西安,西北电讯工程学院的红卫兵组织则与西安戏曲学校的红卫兵组织联手,赴北京全国人大,将原陕西省省长,时任全国人大常委会副秘书长的赵伯平揪回西安。随后周恩来即指示陕西省军区,将习仲勋、赵伯平交由部队军事监护看管,送至建国路七十三号。
  先后被关的干部还有:
  习仲勋(国务院原副总理兼秘书长);高克林(西北局书记处书记);刘澜涛(西北局第一书记);王甫(西北局书记处书记);、、、刘邦显(陕西省副省长);林茵如(陕西省副省长、省人委秘书长);张毅忱(西北局财贸办公室副主任);甘一飞(西安冶金建筑学院原党委书记,文革前任十三冶党委副书记);白瑞生(陕西省委副秘书长兼省委办公厅主任);李骥德(陕西省人委副秘书长);
  
  十年文革期间,陕西省是重灾区,当时的陕西被污称是“胡宗南、国民党的反革命老巢”“彭德怀、高岗、习仲勋在西北苦心经营的反革命政变据点”“土改、镇反不彻底”
“敌情严重”“有一股右倾复辟势力”“陕西地下党严重不纯”“是第二国民党”等等。
文革中在这种“怀疑一切”“打倒一切”的极左思想影响下,全省立案审查的脱产干部达
68024人,占全省脱产干部总数的17·4%,其中省级干部被立案审查的占同级干部总数的90%,厅、局级干部被立案审查的占同级干部总数的70%以上。在审查干部时,不少地方出现了由群众组织任意审查干部,由个人决定干部处理,调查取证采取各取所需、断章取义、东拼西凑、添枝加叶等手段,更为严重的是有的违反党的纪律和社会主义法治,随意关押干部,大搞逼、供、信,造成了大量冤假错案。新中国成立后四届省委常委中大多数人在文革中被打成“叛徒”“特务”“彭(德怀)、高(岗)、习(仲勋)死党”和“死不改悔的走资派”;省级机关59%的部、厅、局级领导干部被打成“阶级敌人”;全省1350名干部被拘留,其中县处级干部110人,在《陕西日报》《彻底砸烂反动公检法》的社论煽动下,政法机关被诬蔑为“进行资产阶级专政和反革命政变的重要工具”,以致全省200多个公检法机关被捣毁,大批干部被揪斗、审查,有的地方甚至还采用私设公堂、刑讯逼供等手段,捕风捉影,屈打成招,制造了400多起“集团性反革命”案件,涉及干部6050人。

  中共十一届三中全会后,陕西省开始全面纠正文革的错误,大规模地开展拨乱反正、落实干部政策的工作。1979年5月13日,陕西省委印发《关于“七十三号问题”的调查报告》,《报告》指出:“现已查明,这是一起重大冤案”,“被关入‘七十三号’的所有老干部,没有一个坏人,没有一个叛徒、特务、反革命。”“省委决定,为这一冤案彻底平反。”

□ 原载《炎黄春秋》2015年7月号

1979年4月

4月17日 省委组织部通知,省委决定:李骥德任省出版局党组副书记、副局长。

1982年2月

陕西省第五届人民代表大会常务委员会
任期:1979年12月-1983年4月
主任:马文瑞
副主任:常黎夫、胡炳云、杨文海、时逸之、张毅忱、孙作宾、林茵如、刘海滨、侯宗濂、原政庭、张汉武、董学源、石锋、王杰、熊应栋、刘力贞(女)
秘书长:时逸之(兼) → 李骥德(1982年8月起)

参考

西安二中
一九六三年第八号国务院公报
隐蔽在国民党三青团的李骥德
宝鸡党史-眉县
千阳县
第五届陕西人大常委会
西安七十三号纪事
华夏文摘-七十三号
打入三青团
马德就义
陕西出版业大事记1935~1989
眉县大事纪

plt.show无法显示图片,imread与random.randint生成narray数组的区别

使用np.random.randint生成了数组,但是没法像读取图像后生成的数组,使用plt.show显示图片显示如下错误(估计使用pil图像也是如此)

> Unsupported depth of input image:
>     'VDepth::contains(depth)'
> where
>     'depth' is 4 (CV_32S)

初步分析,应该是与数据类型相关

对比imread与randint生成数组的数据类型

首先,我们看使用randint生成的数组数据类型

img4Random = np.random.randint(0,256,1200,dtype= 'i')
bgrImg4Random  = img4Random.reshape(20,20,3)

这里生成的数组,每个元素的范围是从0~255,但是数据类型是int32(dtype=‘i’)

print(bgrImg4Random[0,0])
print(bgrImg4Random[0,0,0])
print(bgrImg4Random[0,0,1])
print(bgrImg4Random[0,0,2])
type(bgrImg4Random[0,0,2])

显示结果如下

[ 20 103  51]
20
103
51
numpy.int32

如果省略dtype参数,默认数据类型是int64

img4Random = np.random.randint(0,256,1200)

显示结果如下

numpy.int64

现在我们看看从jpg生成的数组情况,如下

img1 = cv2.imread("ls.jpg")
print(img1[0,1,0])
type(img1[0,0,0])

数据类型是 unit8,也可以用print(image1.dtype)来显示数据类型

33
numpy.uint8

转换数组的数据类型

使用np.unit8或者astype两种方式都可以进行转换到unit8

bgrImg4Random  = img4Random.reshape(20,20,3)
#bgrImg4Random = np.uint8(bgrImg4Random)
#bgrImg4Random=bgrImg4Random.astype(np.uint8)

图像显示出来了,随机的3通道图像,20*20个像素
Screen Shot 2021-03-06 at 2.37.07 PM

参考

数据读入就是unit8,使用np.unit8转换,这里介绍了pil图像,暂时我没有使用过;
解释opencv灰度图和RGB图数据类型,int是32位,而8位就足够了,采用int会浪费存储空间。
介绍opencv处理图像使用unit8

cv2.imshow() crashes Kernel

用pyplot.imshow取代cv2.imshow

我在运行cv2.imshow和destroyAllWindows时,Jupyter notebook出现如下告警,然后Visual studio code崩溃,必须重启才能正常。

Error: Direct kernel connection broken

githhub上分析这不是notebook问题,应该与ipython或ipykernel有关。

后来采用matplotlib的pyplot函数,效果更好

%matplotlib inline
from matplotlib import pyplot as plt
img1 = cv2.imread("ls.jpg")
plt.imshow(img1)
plt.show()

Screen Shot 2021-02-27 at 6.31.42 PM

cv2是BGR与pyplot是RGB

为什么上图人脸发蓝,因为图片是用cv2读取的,颜色顺序是BGR,而pyplot是RGB,因此需要做一个转换。

plt.imshow(cv2.cvtColor(img1, cv2.COLOR_BGR2RGB))
#plt.imshow(img1)
plt.show()

Screen Shot 2021-02-27 at 10.26.00 PM
Screen Shot 2021-02-27 at 10.25.46 PM

参考
stackoverflow
github
BGR2RGB

Learning OpenCV Day one

运行demo文件:

import cv2
image = cv2.imread('MyPic.png')
cv2.imwrite('MyPic.jpg', image)

出现如下错误

cv2.error: OpenCV(4.5.1) /tmp/opencv-20210108-6455-1src644/opencv-4.5.1/modules/imgcodecs/src/loadsave.cpp:753: error: (-215:Assertion failed) !_img.empty() in function 'imwrite'

修改mypic.png为绝对路径(/Users/m…/Study/learningOC/MyPic.png),修复完成。

解决opt_flow.py问题

terminal问题

昨天测试opt_flow还正常,今天发现在studio code下面就现实无法获取摄像头权限(hist.py都正常),命令行模式也无法运行。
做了如下修改:

brew update-reset

同时修改了pip的源(从清华修改为科大)。
因为做了两个操作,我也不清楚是哪个起了作用,命令行模式是ok了。

vscode问题

国外大拿分析(见参考),vscode下opcv摄像头没有权限,是由于apple mac没有给予vscode权限,在system preference里的camera部分,也没有能够增加vscode的地方,因此需要直接修改security&privacy存储数据的地方,见下面。完成后重启vscode即可(修改前,需要在system preference里授予terminal-Full Disk Access权限)

cd ~/Library/Application Support/com.apple.TCC
cp TCC.db TCC.db_backup
sqlite3 TCC.db
INSERT into access (service, client, client_type, auth_value, auth_reason, auth_version) VALUES ("kTCCServiceCamera","com.microsoft.VSCode",0,2,0,1);
INSERT into access (service, client, client_type, auth_value, auth_reason, auth_version) VALUES ("kTCCServiceMicrophone","com.microsoft.VSCode",0,2,0,1);
.exit

Screen Shot 2021-02-22 at 21.55.12

参考
vscode获得camera权限

pip3使用国内源更新&解决futu-api库安装问题

方法1

使用如下命令。

python3 -m pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade pip

但是在安装futu-api时,总是报错,如下
Screen Shot 2021-02-21 at 18.52.38

分析核心问题应该是

WARNING: You are using pip version 20.2.3; however, version 21.0.1 is available.
You should consider upgrading via the '/usr/local/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip' command.

采用方法1的时候,很有可能并没有更新pip3,还是在错误的目录下下载文件。
所以需要首先确定pip3的版本最新,那么只有进行全局变量的配置,见方法2

方法2

mac和linux配置方法相同

mkdir ~/.pip
vi ~/.pip/pip.conf

在文件中粘贴如下内容,用科大源替换也可以。

[global]
 
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
 
trusted-host = pypi.tuna.tsinghua.edu.cn

然后升级

sudo pip3 install --upgrade pip

Screen Shot 2021-02-21 at 19.01.32

参考
替换pip国内源
替换pip国内源/tencent

国内的pip源

阿里云:https://mirrors.aliyun.com/pypi/simple/
清华:https://pypi.tuna.tsinghua.edu.cn/simple
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/

解决No module name ‘futu’问题

运行futu给的demo代码,总是出现如下错误,找不到futu api这个库
Screen Shot 2021-02-21 at 22.35.10
但是采用python2调用时,则没有类似告警。
这基本可以判断,问题是mac上有两套python环境导致的(mac自带python2环境)。
解决方法如下

  1. 在python3下运行如下代码,获得python3的interpreter路径

    >>> import sys
    >>> print(sys.executable)
    /usr/local/opt/python@3.9/bin/python3.9
  2. 在命令行下(注意,不是python环境下),进入interpreter路径执行安装futu-api命令
    不过这里我也没有搞懂,为什么不适用pip3也能安装成功

    ➜ /usr/local/opt/python@3.9/bin/python3.9 -m pip install futu-api
    

    下面则是执行demo代码成功的结果。
    Screen Shot 2021-02-21 at 22.45.57

参考
富途Q&A