76 lines
4.6 KiB
Plaintext
76 lines
4.6 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"metadata": {},
|
|
"cell_type": "markdown",
|
|
"source": "re",
|
|
"id": "9100b86a92c5dc60"
|
|
},
|
|
{
|
|
"metadata": {
|
|
"ExecuteTime": {
|
|
"end_time": "2025-10-20T06:26:47.364635Z",
|
|
"start_time": "2025-10-20T06:26:47.327525Z"
|
|
}
|
|
},
|
|
"cell_type": "code",
|
|
"source": [
|
|
"import re\n",
|
|
"\n",
|
|
"with open (\"D:\\Idea Project\\F6+宜搭+其它(1)\\张阳脚本\\text.txt\",\"r\",encoding=\"utf-8\") as f:\n",
|
|
" text = f.read()\n",
|
|
" print(re.findall(r\"/{[^}]*}\",text))"
|
|
],
|
|
"id": "2d9dc300d83e2ff3",
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"<>:3: SyntaxWarning: invalid escape sequence '\\I'\n",
|
|
"<>:3: SyntaxWarning: invalid escape sequence '\\I'\n",
|
|
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_27692\\3995594842.py:3: SyntaxWarning: invalid escape sequence '\\I'\n",
|
|
" with open (\"D:\\Idea Project\\F6+宜搭+其它(1)\\张阳脚本\\text.txt\",\"r\",encoding=\"utf-8\") as f:\n",
|
|
"C:\\Users\\zy187\\AppData\\Local\\Temp\\ipykernel_27692\\3995594842.py:3: SyntaxWarning: invalid escape sequence '\\I'\n",
|
|
" with open (\"D:\\Idea Project\\F6+宜搭+其它(1)\\张阳脚本\\text.txt\",\"r\",encoding=\"utf-8\") as f:\n"
|
|
]
|
|
},
|
|
{
|
|
"ename": "OSError",
|
|
"evalue": "[Errno 22] Invalid argument: 'D:\\\\Idea Project\\\\F6+宜搭+其它(1)\\\\张阳脚本\\text.txt'",
|
|
"output_type": "error",
|
|
"traceback": [
|
|
"\u001B[31m---------------------------------------------------------------------------\u001B[39m",
|
|
"\u001B[31mOSError\u001B[39m Traceback (most recent call last)",
|
|
"\u001B[36mCell\u001B[39m\u001B[36m \u001B[39m\u001B[32mIn[3]\u001B[39m\u001B[32m, line 3\u001B[39m\n\u001B[32m 1\u001B[39m \u001B[38;5;28;01mimport\u001B[39;00m\u001B[38;5;250m \u001B[39m\u001B[34;01mre\u001B[39;00m\n\u001B[32m----> \u001B[39m\u001B[32m3\u001B[39m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mopen\u001B[39m (\u001B[33m\"\u001B[39m\u001B[33mD:\u001B[39m\u001B[33m\\\u001B[39m\u001B[33mIdea Project\u001B[39m\u001B[33m\\\u001B[39m\u001B[33mF6+宜搭+其它(1)\u001B[39m\u001B[33m\\\u001B[39m\u001B[33m张阳脚本\u001B[39m\u001B[38;5;130;01m\\t\u001B[39;00m\u001B[33mext.txt\u001B[39m\u001B[33m\"\u001B[39m,\u001B[33m\"\u001B[39m\u001B[33mr\u001B[39m\u001B[33m\"\u001B[39m,encoding=\u001B[33m\"\u001B[39m\u001B[33mutf-8\u001B[39m\u001B[33m\"\u001B[39m) \u001B[38;5;28;01mas\u001B[39;00m f:\n\u001B[32m 4\u001B[39m text = f.read()\n\u001B[32m 5\u001B[39m \u001B[38;5;28mprint\u001B[39m(re.findall(\u001B[33mr\u001B[39m\u001B[33m\"\u001B[39m\u001B[33m/\u001B[39m\u001B[33m{\u001B[39m\u001B[33m[^}]*}\u001B[39m\u001B[33m\"\u001B[39m,text))\n",
|
|
"\u001B[36mFile \u001B[39m\u001B[32mD:\\ProgramTools\\anaconda3\\envs\\f6\\Lib\\site-packages\\IPython\\core\\interactiveshell.py:326\u001B[39m, in \u001B[36m_modified_open\u001B[39m\u001B[34m(file, *args, **kwargs)\u001B[39m\n\u001B[32m 319\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m file \u001B[38;5;129;01min\u001B[39;00m {\u001B[32m0\u001B[39m, \u001B[32m1\u001B[39m, \u001B[32m2\u001B[39m}:\n\u001B[32m 320\u001B[39m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mValueError\u001B[39;00m(\n\u001B[32m 321\u001B[39m \u001B[33mf\u001B[39m\u001B[33m\"\u001B[39m\u001B[33mIPython won\u001B[39m\u001B[33m'\u001B[39m\u001B[33mt let you open fd=\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mfile\u001B[38;5;132;01m}\u001B[39;00m\u001B[33m by default \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 322\u001B[39m \u001B[33m\"\u001B[39m\u001B[33mas it is likely to crash IPython. If you know what you are doing, \u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 323\u001B[39m \u001B[33m\"\u001B[39m\u001B[33myou can use builtins\u001B[39m\u001B[33m'\u001B[39m\u001B[33m open.\u001B[39m\u001B[33m\"\u001B[39m\n\u001B[32m 324\u001B[39m )\n\u001B[32m--> \u001B[39m\u001B[32m326\u001B[39m \u001B[38;5;28;01mreturn\u001B[39;00m io_open(file, *args, **kwargs)\n",
|
|
"\u001B[31mOSError\u001B[39m: [Errno 22] Invalid argument: 'D:\\\\Idea Project\\\\F6+宜搭+其它(1)\\\\张阳脚本\\text.txt'"
|
|
]
|
|
}
|
|
],
|
|
"execution_count": 3
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 2
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython2",
|
|
"version": "2.7.6"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 5
|
|
}
|