Home > other >  About the python language in the Windows system development to the OS problem for help
About the python language in the Windows system development to the OS problem for help

Time:11-16

Good god, I am a little white, ask an intern to help before I developed a small module, but he is in the development of the Windows, my computer is apple, later I was in my apple system running, the results found that operation error, so I want to ask a great god, and there only can match the apple how to modify the system running? Apple is I use pycharm operation,

Ps: I started to write the first line of source code deleted can run on Windows, but the line 54 calls his powerpoint software module is also not line, programming small white,,,,

 
import win32com. Client, sys I delete the below error here
The import OS
The import math

If __name__=="__main__ ':

Current_address=OS. The path. The dirname (OS) path) abspath (__file__))

# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- each PPT relative address is stored in the two-dimensional list
Print (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ')
Print (' module PPT file information ')
Print (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ')
Path_list=[[0 for col in range (20)] for a row in the range (20)] # to create 20 * 20 two-dimensional list, storing the addresses of each PPT file
Module_index=0
For the parent, dirnames, filenames in OS. Walk (current_address) :
For each_module dirnames in:
Module_index=module_index + 1
# module_name [module_index]=each_module
Print (" module ", module_index, ":", each_module)
File_index=0
File_list=OS. Listdir (each_module) # get each_module below the names of all the PPT file
For each_file in file_list:
File_index=file_index + 1
Print (" file ", file_index, ":", each_file)
File_path=current_address + '\ \' + each_module + '\ \' + each_file # each PPT file address=in folder code + module name + file name
File_path=file_path. Replace (' \ \ ', '/') # absolute path to a relative path
Path_list [module_index] [file_index]=file_path
# print (list [module_index] [file_index])

# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - the user's choice, is stored in the vector formats: & lt; The module number, file number & gt;
Print ()
Print (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ')
Print (" please enter your choice of PPT file in sequence, input format is: module serial number file number ')
Print (' after all file selection, please enter: 0 0 ')
Print (" -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - ')

Class Vector (object) :
Def __init__ (self, x, y) :
Self. X=x
The self. The y=y

M=1
N=1
Choice_list={}
I=1
While m & gt; 0:
Print (' you choose the first 'I,' a PPT file: 'end=' ')
M, n=map (int, input (). The split ())
V=Vector (m, n)
Choice_list [I]=v
I=I + 1
# print (choice_list)

# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- traverse choice, combined PPT
Application=win32com. Client. Dispatch (" PowerPoint. Application ")
Application. The Visible=True
# to create a new blank PPT object
New_ppt=Application. Presentations. The Add ()

For each_choice choice_list in:
# print (each_choice)
# print (choice_list [each_choice])
# print (choice_list [each_choice]. The module ())
File_path=path_list [choice_list [each_choice]] x [choice_list [each_choice] y]
Exit_ppt=Application. Presentations. Open (file_path)
Page_num=exit_ppt. Slides TAB. Count
Exit_ppt. Close ()
Num=new_ppt. Slides TAB. InsertFromFile (file_path, new_ppt. Slides TAB. The Count, 1, page_num)

# new_ppt. SaveAs (r 'D: \ \ python homework set combined PPT \ new_ppt PPTX')
The Presentation. The Save ()
Application. The Quit ()

CodePudding user response:

Used macos, don't know the reason, but you can guess, win32 is Windows interface, should be unable to call on macos,

CodePudding user response:

Win32 is a Windows interface, the system not the same, must not take on the MAC,
Haven't heard of the MAC OS interface,
MAC is generally not have dual system, carried out simply to win,

CodePudding user response:

In addition, python operation PPT is not upset, is basically useless, not on the productivity level, so there is nothing to use package,
But really want to do cross-platform, also has a real way,



Each PPT, doc or word, are essentially the package (you can think of. PPT to. Rar can see)
Then find a intern, let he USES python to change the text inside, back again after save. PPT, the effect is the same,
A little round, but the basic is to move the brick, nothing technical content


CodePudding user response:

PIP install python - PPTX

CodePudding user response:

These is a font color control, not standard python code to delete can be used
  • Related